package engine

import (
    "github.com/rthornton128/goncurses"
)

type Screen struct {
    window *goncurses.Window
}

func (screen *Screen) Init() error {
    var err error
    screen.window, err = goncurses.Init()
    if(err != nil) {
        return err
    }
    goncurses.Raw(true)
    goncurses.Echo(false)
    goncurses.Cursor(0)
    screen.window.Keypad(true)
    return nil
}

func (screen *Screen) SetChar(x, y int, char rune) {
    screen.window.MoveAddChar(y, x, goncurses.Char(char))
}

func (screen *Screen) Width() uint {
    _, col := screen.window.MaxYX()
    return(uint(col))
}

func (screen *Screen) Height() uint {
    row, _ := screen.window.MaxYX()
    return uint(row)
}

func (screen *Screen) Update() {
    screen.window.Refresh()
}

func (screen *Screen) Quit() {
    goncurses.End()
}
